<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<link href="../css/mui.picker.css" rel="stylesheet" />
		<link href="../css/mui.poppicker.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../css/icons-extra.css" />
		<style>
			.imgSize {
				width: 30px;
				height: 10px;
				float: left;
			}
			
			.p0Style {
				float: left;
				color: #000000;
				width: 100%;
				font-family: "微软雅黑";
			}
			
			.p4Style {
				float: left;
				color: #000000;
				font-family: "微软雅黑";
			}
			
			a.focus {
				background: #ff0000;
				color: #ffffff;
			}
			
			.inputStyle {
				float: left;
				color: #000000;
				width: 100%;
			}
			
			.mui-btn {
				padding: 1px;
				margin: -5px;
			}
			
			.box input {
				width: 10px;
				height: 30px;
				margin: 10px 0;
				background: url(../images/saoyisao.jpg) no-repeat;
				background-size: 30px 25px;
				padding-left: 17px;
				border-style: none none none none;
			}
			
			#bcid {
				background: #0F0;
				height: 480px;
				width: 360px;
			}
		</style>
	</head>

	<body>
		<!--搜索框-->
		<div class="mui-page-content">
			<div class="mui-bar mui-bar-nav" style="height: 60px;">
				<div style="margin-top: 20px;">
					<h1 class="mui-title">
			<div class="container" >
				<input id="input_search" type="search" class="mui-input-clear"  placeholder="找工作  找小区" value="">
			</div>
			</h1>
					<li class="mui-btn mui-btn-link mui-pull-right">
						<div class="button" onclick="notice()">
							<span style="font-size:xx-large;  margin-top: 5px;padding-right: -1px ; " class="mui-icon mui-icon-chatbubble mui-icon-extra-sweep"><span id="notice_num" class="mui-badge" style="display:  ;">+</span></span>
						</div>
					</li>
					<li class="mui-btn mui-btn-link mui-pull-left">
						<div class="button" onclick="clicked()">
							<span style="font-size:x-large;  margin-top: 10px;padding-right: -10px ; margin-left: 5px;" class="mui-icon-extra mui-icon-extra-sweep"></span>
						</div>
					</li>
				</div>
			</div>
			<div id="pullrefresh" class="mui-slider-item mui-scroll-wrapper">
				<div class="mui-scroll">
					<div class="mui-content">
						<div id="choose2" class="mui-segmented-control mui-segmented-control-inverted" style="background-color:azure;">
							<div class="mui-content" style="display:  ;width: 100%;">
								<!--订单倒计时-->
								<div id="count_down" style="display: none;width: 100%;">
									<div class="time-item" style="width: 100%;">
										<!--<span id="day_show">0天</span>-->
										<span style="margin-left: 25%;">订单倒计时：</span>
										<strong id="hour_show">0时</strong>
										<strong id="minute_show">0分</strong>
										<strong id="second_show">0秒</strong>
									</div>
								</div>
							</div>
							<!--图片轮播-->
							<div id="slider" class="mui-slider" style="margin-top: 14%;">
								<div class="mui-slider-group mui-slider-loop" id="advert">
								</div>
								<div class="mui-slider-indicator mui-text-right" id="advert2">
								</div>
							</div>
							<!--自动定位-->
							<div class="mui-card-content" style="margin-top: 5px;">
								<button id='showCityPicker3' type='button' style="width: 90%;margin-left: 5%;">自动定位</button>
								<div id='cityResult3'></div>
							</div>
							<!--工种获取    需要改-->
							<div class="mui-card">
								<div class="mui-card-content">
									<div class="mui-card-content-inner" id="choose_jobtype">
										<table border="0" width="100%" height="80px">
											<tr>
												<td align="center" valign="middle"><span class="iconfont icon-xiaorener"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="41" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(41)" value="力工">
													</input>
												</td>
												<td align="center" valign="middle" width="33%"><span class="iconfont icon-huabi"></span>&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="23" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(23)" value="木工">
													</input>
												</td>
												<td align="center" valign="middle" width="33%"><span class="iconfont icon-shuitong"></span>&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="22" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(22)" value="水工">
													</input>
												</td>
											</tr>
											<tr>
												<td align="center" valign="middle" width="33%"><span class="iconfont icon-gongjuxiang"></span>&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="21" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(21)" value="电工">
													</input>
												</td>
												<td align="center" valign="middle" width="33%"><span class="iconfont icon-dashuazi"></span>&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="33" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(33)" value="油工">
													</input>
												</td>
												<td align="center" valign="middle" width="33%"><span class="iconfont icon-guadao"></span>&nbsp;&nbsp;&nbsp;&nbsp;
													<input class="mui-btn mui-btn-primary mui-btn-outlined" type="submit" id="25" style="background-color: white;font-weight:bolder;font-size: 18px;" onclick="jobtype_choose(25)" value="瓦工">
													</input>
												</td>
											</tr>
										</table>
									</div>
								</div>
							</div>
						</div>
						<!--上下拉刷新容器-->
						<ul class=" mui-table-view " id="show" style="margin-top: -2.5%;">
						</ul>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/urlconfiguration.js"></script>
	<script src="../js/mui.picker.min.js"></script>
	<script src="../js/mui.poppicker.js"></script>
	<script src="../js/city.data.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/jquery-1.6.2.min.js"></script>
	<script>
		var flag = 0;
		var types_id = [];
		var lists;
		var data_flag = [];
		var county_code, province_code, city_code;
		var jobitem_user_id;
		var name = localStorage.getItem("name");
		var district, city, province, unit, house;
		var user_id = localStorage.getItem("user_id");
		var beans = localStorage.getItem("beans");
		var users = JSON.parse(localStorage.getItem('$users') || '[]');
		var input_search;
		var jumpFlag;
		var page = 1;
		var temp = 0;
		window.addEventListener('refreshmain', function(e) {
			//在父页面中添加监听事件，刷新页面
			location.reload();
		});

		//      <!--区域选择-->
		(function($, doc) {
			$.init();
			$.plusReady(function() {
				get_address();
				document.getElementById("input_search").addEventListener("click", function() {
					var county_code_search = localStorage.getItem("county_code");
					var showCityPickerButton = document.getElementById("showCityPicker3").innerText; 
					localStorage.setItem("showCityPickerButton", showCityPickerButton);
					localStorage.setItem("county_code_search", county_code_search);
					document.activeElement.blur(); //软键盘收起
					mui.openWindow({
						url: 'search.html',
						extras: {
							user_id: user_id
						}
					})
					page = 1;
					console.log("clickpage:" + page)
				})
				/**
				 * 获取对象属性的值
				 * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
				 * @param {Object} obj 对象
				 * @param {String} param 属性名
				 */
				var _getParam = function(obj, param) {
					return obj[param] || '';
				};
				var cityPicker3 = new $.PopPicker({
					layer: 3
				});
				cityPicker3.setData(cityData3);
				var showCityPickerButton = doc.getElementById('showCityPicker3');
				var cityResult3 = doc.getElementById('cityResult3');
				showCityPickerButton.addEventListener('tap', function(event) {
					up_page();
					cityPicker3.show(function(items) {
						showCityPickerButton.innerText = _getParam(items[0], 'text') + " " + _getParam(items[1], 'text') + " " + _getParam(items[2], 'text');
						county_code = (_getParam(items[2], 'value'));
						localStorage.setItem("county_code_search", county_code);
						localStorage.setItem("showCityPickerButton", showCityPickerButton.innerText);
						page = 1;
						checkIt();
						//返回 false 可以阻止选择框的关闭
						return county_code;
					});
				}, false);
			});
			$.init({
				pullRefresh: {
					container: '#pullrefresh',
					down: {
						callback: pulldownRefresh
					},
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});
		})(mui, document);

		function up_page() {
			temp++;
			$("body").scrollTop(temp);
		}
		//扫一扫
		function clicked() {
			var baseUrl = 'barcode_scan.html';
			var url = mui.os.plus ? baseUrl : baseUrl + '?userid=' + user_id;
			mui.openWindow({
				url: url,
				extras: {
					user_id: user_id
				}
			})

		}
		function search() {
			
			var baseUrl = 'search.html';
			var url = mui.os.plus ? baseUrl : baseUrl + '?userid=' + user_id;
			mui.openWindow({
				url: url,
				extras: {
					user_id: user_id
				}
			})

		}
		//消息查看
		function notice() {
			$("#notice_num").css('display', 'none');
			//			window.location.href = "pullrefresh_main.html"
			var baseUrl = 'notice.html';
			var url = mui.os.plus ? baseUrl : baseUrl + '?userid=' + user_id;
			mui.openWindow({
				url: url,
				extras: {
					user_id: user_id
				}
			})
		}

		function notice_num() {
			var z = 0;
			$.ajax({
				contentType: "application/json",
				type: "get",
				url: url_2 + "front_get_messages.do?jsoncallback=?",
				data: "user_id=" + user_id,
				dataType: "json",
				success: function(data) {
					if(data.list == null || data.list == "") { 
						$("#notice_num").css('display', 'none');
					} else { 
						for(i = 0; i < data.list.length; i++) {
							if(data.list[i].checkstatus == 0) {
								z++;
							}
						}
						if(z == 0) { 
							$("#notice_num").css('display', 'none');
						}else{
							$("#notice_num").css('display', ' ');
						}
					}
				},
				error: function(data) {
					alert(data);
					alert("网络连接出错！");
				}
			});
		}
		//      广告展示
		function pictureturn() {
			$("#advert").empty();
			$("#advert2").empty();
			console.log("县区号" + county_code);
			console.log("市号:" + city_code);
			console.log("省号:" + province_code);
			$.ajax({
				contentType: "application/json",
				type: "get",
				url: url_2 + "front_get_advertisment.do?jsoncallback=?",
				data: "province_code=" + province_code + "&city_code=" + city_code + "&county_code=" + county_code,
				dataType: "json",
				success: function(data) {
					if(data.list.length > 0) {
						for(i = 0; i < data.list.length + 2; i++) {
							z = i;
							if(i == data.list.length) {
								z = 0;
							}
							if(i == (data.list.length + 1)) {
								z = 1;
							}
							var img_url = url_1 + data.list[z].img_url;
							console.log(img_url + "imgurl")
							$("#advert").append('<div class="mui-slider-item">' +
								'<input id="img_url_' + i + '" src="' + img_url + '" type="submit" onclick="adverts(' + i + ')" value=" " style="width:100%;height: 150px; background: url(' + img_url + ') no-repeat;background-size:100% 100%;border-style:none none none none; ">' +
                                //								'<img onclick="adverts(' + i + ')" src="' + img_url + '"  style="height: 150px;" id="img_url_' + i + '">' +
								//                              '<img onclick="adverts(' + i + ')" src="' + img_url + '"  style="height: 150px;" id="img_url_' + i + '">' +
								'<p class="mui-slider-title" id="title_' + i + '" >' + data.list[z].title + '</p>' +
								'<p class="mui-slider-title" id="content_' + i + '"  style="display: none;" >' + data.list[z].content + '</p>' +
								'</a>' + '</div>');
							if(i < data.list.length) {
								$("#advert2").append('<div class="mui-indicator "></div>');
							}

						}
						//		图片滚动轮播
						var gallery = mui('.mui-slider');
						gallery.slider({
							interval: 2000 //自动轮播周期，若为0则不自动播放，默认为0；
						});
					}

				},
				error: function(data) {
					alert(data);
					alert("网络连接出错！");
				}
			});
		}

		//工种获取
		function get_jobtype() {
			$.ajax({
				contentType: "application/json",
				type: "get",
				url: url_2 + "front_get_jobtypes.do?jsoncallback=?",
				dataType: "json",
				success: function(data) {
					if(data.list.length != null) {
						lists = data.list.length;
						for(i = 0; i < data.list.length; i++) {
							z = data.list[i].id;
							types_id[i] = z;
							$("#choose_jobtype").append(
								'<button id="checkbox' + i + '" onclick="jobtype_choose(' + i + ')"> ' + data.list[i].name + '</button>;'					
							);
							console.log("get_jobtype:jobtype_id" + z);
						}
					} else {
						mui.alert("工种获取失败！");
					}

				},
				error: function(data) {
					alert("网络连接出错！");
				}
			});
		}

		//查看广告
		function adverts(id) {
			var content = $("#content_" + id).html();
			var img_url = $("#img_url_" + id).attr("src");
			var title = $("#title_" + id).html();
			var baseUrl = 'advert.html';
			var url = mui.os.plus ? baseUrl : baseUrl + '?content=' + content + '&?img_url=' + img_url + '&?title' + title;
			mui.openWindow({
				url: url,
				extras: {
					content: content,
					img_url: img_url,
					title: title
				}
			})
		}
		//查看详细信息页面
		function order_info(jobitem_id, boss_id, flag) {
			console.log("order_info:发布订单id" + jobitem_id);
			console.log("工长id" + boss_id);
			var baseUrl = '../order/order_info.html';
			var url = mui.os.plus ? baseUrl : baseUrl + '?jobitem_id=' + jobitem_id + '?boss_id' + boss_id + "?flag" + flag;

			mui.openWindow({
				url: url,
				extras: {
					jobitem_id: jobitem_id,
					boss_id: boss_id,
					flag: flag
				}

			})
		}

		//输入框搜索
		function search() {
			setTimeout(function() {
				var w = plus.nativeUI.showWaiting("正在加载...\n");
				var table = document.body.querySelector('.mui-table-view');
				var cells = document.body.querySelectorAll('.mui-table-view-cell'); 
				county_code = localStorage.getItem("county_code_search");
				var showCityPickerButton = localStorage.getItem("showCityPickerButton");
				document.getElementById('showCityPicker3').innerText = showCityPickerButton;
				console.log(county_code+showCityPickerButton)

				$.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_3 + "show_jobitems.do?jsoncallback=?",
					data: "county_code=" + county_code + "&string=" + input_search + "&user_id=" + user_id + "&page_num=" + page,
					dataType: "json",
					success: function(data) {
						page++;
						console.log("searchpage" + page)
						console.log("searchnote" + input_search)
						if(data.msg != null && data.msg.length > 0) {
							console.log(data.msg.length)
							var cells = document.body.querySelectorAll('.mui-table-view-cell');
							for(i = 0, num = 0; i < data.msg.length; i++) {
								var li = document.createElement('li');
								li.className = 'mui-card';
								console.log("i" + i)
								num = i + page * 10 - 20
								console.log("num" + num)
								if(data.msg[i] == null) {
									main.do
									mui.alert("没有数据了！");
									return;
								} else {
									if(data.msg[i].jobitem.job.decoration_type == 1) {
										house = "毛坯";
									} else {
										house = "旧房改造";
									}
									if(data.msg[i].jobitem.unit == 1) {
										unit = "平米";
									} else {
										unit = "延米";
									}
									li.innerHTML = '<table class="p0Style" style="margin-left:10px" ><tr><td class=" mui-badge mui-badge-warning"><h4>' + data.msg[i].jobitem.jobtype.name + '</h4></td><td class=" mui-badge mui-badge-green" id="urgent_fee_' + data.msg[i].jobitem.id + '" style="display: none;"><h4>加急费:' + data.msg[i].jobitem.urgent_fee + '</h4></td><td class=" p4Style"><h3>' + data.msg[i].jobitem.job.community + '</h3></td></tr><br />' +
										'<tr class="p4Style"><td style="color:#ECB100;">面积：' + data.msg[i].jobitem.area + unit + '</td></h6></tr>' +
										//									'<table class="p4Style"><tr><td class="mui-badge mui-badge-warning">&nbsp;&nbsp;&nbsp;工种：' + data.msg[i].jobtype.name + '</td></tr></table>' +
										'<tr id="show' + num + '"><td class="mui-pull-left">技能:</td></tr>' +
										'<table class="p4Style" style="margin-left:10px" ><tr><td>房屋类型：' + house + '</td>' +
										'<td>&nbsp;&nbsp;&nbsp;酬劳：' + data.msg[i].jobitem.salary + '元</td></tr>' +
										'<tr><td class="mui-pull-left">接单：' + data.msg[i].user_num + '人</td></tr></table>' +
										'<table class="mui-pull-right" style="margin-left:10px" ><tr><td><input type="submit" value="详情" class="mui-pull-right" onclick="order_info(' + data.msg[i].jobitem.id + ',' + data.msg[i].jobitem.job.user.id + ',' + flag + ')">&nbsp;</td>' +
										'<td><input type="submit" value="接单" id="get_order_' + data.msg[i].jobitem.id + '" class="mui-pull-right"  onclick="get_order_onclick(' + data.msg[i].jobitem.id + ')">&nbsp;</td>' +
										'<td><input type="submit" value="分享" class="mui-pull-right">&nbsp;</td><td>&nbsp;</td></tr><tr><td style="height:2px"> </td></tr></table>'
									table.appendChild(li);
									for(z = 0; z < data.msg[i].skills.length; z++) {
										$("#show" + num).append(
											'<td id="p' + data.msg[i].skills[z].id + 'Style" class="mui-pull-left">' + data.msg[i].skills[z].name + '&nbsp;</td>'
										);
										if(data.msg[i].jobitem.urgent_fee != 0) {
											document.getElementById("urgent_fee_" + data.msg[i].jobitem.id).setAttribute("style", "display: ;");
										}
									}
								}
							}
							w.close();
						} else {
							if($("#last_line").text()=="到底啦...."){
								w.close();
							    mui.alert("没有数据啦！");
							    return;
							}else{
							console.log($("#last_line").text())
							var li = document.createElement('li');
							li.className = 'mui-card';  
							li.innerHTML = '<div id="last_line" style="margin-left:45%" value="1">到底啦....</div>'
						    table.appendChild(li);
							w.close();
							mui.alert("没有数据啦！");
							}
						}
					},
					error: function() {
						w.close();
						alert("网络连接出错！");
					}

				});
			}, 500);
			mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
		}
		//自动定位

		// 通过定位模块获取位置信息
		function get_address() {
			plus.geolocation.getCurrentPosition(geoInf, function(e) {
				mui.alert("获取定位位置信息失败：" + e.message);
			}, {
				provider: 'baidu',
				enableHighAccuracy: true,
				geocode: true
			});
		}

		//等待加载图标函数 
		function Waiting() {
			var w = plus.nativeUI.showWaiting("正在加载...\n");
			w.onclose = function() {
				clearInterval(t);
			}
			var n = 3;
			var t = setInterval(function() {
				n--;
				w.setTitle("处理中，请等待5...\n" + n);
				if(n <= 0) {
					w.close();
					clearInterval(t);
				}
			}, 1000);
		}

		//js获取地址函数
		function geoInf(position) {
			//Waiting();
			district = position.address.district;
			city = position.address.city;
			province = position.address.province;
			var str = "";
			str += position.address.province + "\n"; //获取地址信息
			str += position.address.city + "\n";
			str += position.address.district + "\n";
			var str2 = "";
			str2 += position.address.province + "   "; //获取地址信息
			str2 += position.address.city + "   ";
			str2 += position.address.district;
			$('#showCityPicker3').html(str);

			county_code = search_address(district, city, province); //获取区、县的id
			province_code = search_address_province(province); //获取省的id
			city_code = search_address_city(city, province); //获取市的id
			localStorage.setItem("county_code", county_code);
			localStorage.setItem("province_code", province_code);
			localStorage.setItem("city_code", city_code);
			localStorage.setItem("user_address", str); 
			var county_code_search = localStorage.getItem("county_code_search");
			var showCityPickerButton = localStorage.getItem("showCityPickerButton"); 
			if(county_code_search!="null"&&county_code_search!=undefined){
				localStorage.setItem("county_code", county_code_search);
				county_code=county_code_search;
				$('#showCityPicker3').html(showCityPickerButton);
				console.log(county_code_search+showCityPickerButton)
			}
//			if(jumpFlag!=1&&jumpFlag!=2){
//			console.log(jumpFlag+"jumpFlag")
//			localStorage.setItem("county_code_search", county_code);
//			localStorage.setItem("showCityPickerButton", str2);
//			}
//			
			
			checkIt();
		}

		//接单按钮点击事件
		function get_order_onclick(button_id) {
			var w = plus.nativeUI.showWaiting("正在加载...\n");
			beans = localStorage.getItem("beans");
			var user_authenticPer = localStorage.getItem("user_authenticPer");
			if(user_authenticPer != 1) {
				jQuery.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_1 + "get_UserMes.do?jsoncallback=?",
					data: "user_id=" + user_id,
					dataType: "json",
					success: function(data) {
						user_authenticPer = data.user.user_authenticCPer;
						localStorage.setItem("user_authenticPer", user_authenticPer);
					},
					error: function() {
						alert("网络连接出错！");
					}
				});
			}
			if(user_authenticPer == 1) {
				if($("#get_order_" + button_id).val() == "成功接单") {
					w.close();
					mui.alert("您已接此单！");
				} else {
					if(beans < 1) {
						w.close();
						mui.alert("每日最多接5单，今日接单已达上限，明天再来吧！");
					} else {
						$.ajax({
							contentType: "application/json",
							type: "get",
							url: url_3 + "add_jobitem_user.do?jsoncallback=?",
							data: "jobitem_id=" + button_id + "&user_id=" + user_id,
							dataType: "json",
							success: function(data) {
								console.log(data.flag)
								if(data.flag == 3) {
									w.close();
									mui.alert("您已接此单！");
								} else if(data.flag == 1) {
									mui.alert("接单成功");
									w.close();
									jobitem_user_id = data.jobitem_user_id;
									beans = beans - 1;
									localStorage.setItem("beans", beans);
									$("#get_order_" + button_id).val("成功接单");
								} else if(data.flag == 2) {
									mui.alert("每日最多接5单，今日接单已达上限，明天再来吧！");
								}
							},
							error: function(data) {
								w.close();
								alert(data);
								alert("网络连接出错！");
							}
						});
					}
				}
			} else {
				w.close();
				mui.alert("请先去完成实名认证！");
			}
		}

		//进入页面首次加载显示订单函数
		function checkIt() {
			notice_num();
			pictureturn();
			var w = plus.nativeUI.showWaiting("正在加载...\n");
			console.log("用户id" + user_id);
			console.log("地址区号：" + county_code);
			jumpFlag = localStorage.getItem("jumpFlag");
			input_search = localStorage.getItem("input_value");
			console.log("jumpFlag1" + jumpFlag);
			if(jumpFlag == 1) {
				w.close();
				$("#input_search").val(input_search);
				search();
				localStorage.setItem("jumpFlag", 0);
				//				document.getElementById("choose2").style.display = "";
				return;
			} else {
				console.log("wq:")
				$("#input_search").val("");
				document.getElementById("21").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("22").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("23").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("25").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("41").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("33").setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
				document.getElementById("21").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				document.getElementById("22").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				document.getElementById("23").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				document.getElementById("25").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				document.getElementById("41").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				document.getElementById("33").setAttribute("style", "background-color: white;font-weight:bolder;font-size: 18px;");
				$.ajax({
					contentType: "application/json",
					type: "get",
					url: url_3 + "show_jobitems.do?jsoncallback=?",
					data: "county_code=" + county_code + "&page_num=" + page + "&user_id=" + user_id,
					dataType: "json",
					success: function(data) {
						page++;
						console.log("page" + page);
						$("#show").empty();
						beans = localStorage.getItem("beans");
						if(data.msg != null && data.msg.length > 0) {
							for(i = 0; i < data.msg.length; i++) {
								if(data.msg[i] == null) {
									w.close();
									mui.alert("没有数据了！");
									return;
								} else {
									if(data.msg[i].jobitem.job.decoration_type == 1) {
										house = "毛坯";
									} else {
										house = "旧房改造";
									}
									if(data.msg[i].jobitem.unit == 1) {
										unit = "平米";
									} else {
										unit = "延米";
									}
									if(data.msg[i].jobitem.jobtype != null || data.msg[i].jobitem.jobtype != undefined) {
										jobite_jobtype_name = data.msg[i].jobitem.jobtype.name
									} else {
										jobite_jobtype_name = "未选择"
									}
									$("#show").append('<li class="mui-card">' +
										'<table class="p0Style" style="margin-left:10px;" ><tr><td class=" mui-badge mui-badge-warning"><h4>' + jobite_jobtype_name + '</h4></td><td class=" mui-badge mui-badge-green" id="urgent_fee_' + data.msg[i].jobitem.id + '" style="display: none;"><h4>加急费:' + data.msg[i].jobitem.urgent_fee + '</h4></td><td class=" p4Style"><h3>' + data.msg[i].jobitem.job.community + '</h3></td></tr><br />' +
										'<tr class="p4Style"><td style="color:#ECB100;">面积：' + data.msg[i].jobitem.area + unit + '</td></h6></tr>' +
										'<tr id="show' + i + '"><td class="mui-pull-left">技能:</td></tr>' +
										'<table class="p4Style" style="margin-left:10px"><tr><td>房屋类型：' + house + '</td>' +
										'<td>&nbsp;&nbsp;&nbsp;酬劳：' + data.msg[i].jobitem.salary + '元</td></tr>' +
										'<tr><td class="mui-pull-left">接单：' + data.msg[i].user_num + '人</td></tr></table>' +
										'<table class="mui-pull-right"  style="margin-left:10px"><tr><td><input type="submit" value="详情" class="mui-pull-right" onclick="order_info(' + data.msg[i].jobitem.id + ',' + data.msg[i].jobitem.job.user.id + ',' + flag + ')">&nbsp;</td>' +
										'<td><input type="submit" value="接单" id="get_order_' + data.msg[i].jobitem.id + '" class="mui-pull-right"  onclick="get_order_onclick(' + data.msg[i].jobitem.id + ')">&nbsp;</td>' +
										'<td><input type="submit" value="分享" class="mui-pull-right">&nbsp;</td><td>&nbsp;</td></tr><tr><td style="height:2px"> </td></tr></table>' +
										'</li>');
									for(z = 0; z < data.msg[i].skills.length; z++) {
										$("#show" + i).append(
											'<td id="p' + data.msg[i].skills[z].id + 'Style" class="mui-pull-left">' + data.msg[i].skills[z].name + '&nbsp;</td>'
										);
										if(data.msg[i].jobitem.urgent_fee != 0) {
											document.getElementById("urgent_fee_" + data.msg[i].jobitem.id).setAttribute("style", "display: ;");
										}
									}
								}
							}
							w.close();
						} else {
							w.close();
							mui.alert("没有更多数据啦！");
						}
					},
					error: function(data) {
						w.close();
						alert("网络连接出错！");
					}
				});
			}

		}

		//上拉加载具体业务实现
		function pullupRefresh() {
			mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
			if(jumpFlag == 1) {
				search();
				return;
			}
			if(jumpFlag == 2) {
				jobtype_choose(2);
				return;
			}
			setTimeout(function() {
				var w = plus.nativeUI.showWaiting("正在加载...\n");
				var table = document.body.querySelector('.mui-table-view');
				var cells = document.body.querySelectorAll('.mui-table-view-cell');
				$.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_3 + "show_jobitems.do?jsoncallback=?",
					data: "county_code=" + county_code + "&user_id=" + user_id + "&page_num=" + page,
					dataType: "json",
					success: function(data) {
						page++;
						console.log(page)
						if(data.msg != null && data.msg.length > 0) {
							console.log(data.msg.length)
							var cells = document.body.querySelectorAll('.mui-table-view-cell');
							for(i = 0, num = 0; i < data.msg.length; i++) {
								var li = document.createElement('li');
								li.className = 'mui-card';
								console.log("i" + i)
								num = i + page * 10 - 20
								if(data.msg[i] == null) {
									mui.alert("没有数据了！");
									return;
								} else {
									if(data.msg[i].jobitem.job.decoration_type == 1) {
										house = "毛坯";
									} else {
										house = "旧房改造";
									}
									if(data.msg[i].jobitem.unit == 1) {
										unit = "平米";
									} else {
										unit = "延米";
									}
									li.innerHTML = '<table class="p0Style" style="margin-left:10px" ><tr><td class=" mui-badge mui-badge-warning"><h4>' + data.msg[i].jobitem.jobtype.name + '</h4></td><td class=" mui-badge mui-badge-green" id="urgent_fee_' + data.msg[i].jobitem.id + '" style="display: none;"><h4>加急费:' + data.msg[i].jobitem.urgent_fee + '</h4></td><td class=" p4Style"><h3>' + data.msg[i].jobitem.job.community + '</h3></td></tr><br />' +
										'<tr class="p4Style"><td style="color:#ECB100;">面积：' + data.msg[i].jobitem.area + unit + '</td></h6></tr>' +
										'<tr id="show' + num + '"><td class="mui-pull-left">技能:</td></tr>' +
										'<table class="p4Style" style="margin-left:10px" ><tr><td>房屋类型：' + house + '</td>' +
										'<td>&nbsp;&nbsp;&nbsp;酬劳：' + data.msg[i].jobitem.salary + '元</td></tr>' +
										'<tr><td class="mui-pull-left">接单：' + data.msg[i].user_num + '人</td></tr></table>' +
										'<table class="mui-pull-right" style="margin-left:10px" ><tr><td><input type="submit" value="详情" class="mui-pull-right" onclick="order_info(' + data.msg[i].jobitem.id + ',' + data.msg[i].jobitem.job.user.id + ',' + flag + ')">&nbsp;</td>' +
										'<td><input type="submit" value="接单" id="get_order_' + data.msg[i].jobitem.id + '" class="mui-pull-right"  onclick="get_order_onclick(' + data.msg[i].jobitem.id + ')">&nbsp;</td>' +
										'<td><input type="submit" value="分享" class="mui-pull-right">&nbsp;</td><td>&nbsp;</td></tr><tr><td style="height:2px"> </td></tr></table>'
									table.appendChild(li);
									for(z = 0; z < data.msg[i].skills.length; z++) {
										$("#show" + num).append(
											'<td id="p' + data.msg[i].skills[z].id + 'Style" class="mui-pull-left">' + data.msg[i].skills[z].name + '&nbsp;</td>'
										);
										if(data.msg[i].jobitem.urgent_fee != 0) {
											document.getElementById("urgent_fee_" + data.msg[i].jobitem.id).setAttribute("style", "display: ;");
										}
									}
								}
							}
							w.close();
						} else { 
							if($("#last_line").text()=="到底啦...."){
								w.close();
							    mui.alert("没有数据啦！");
							    return;
							}else{
							console.log($("#last_line").text())
							var li = document.createElement('li');
							li.className = 'mui-card';  
							li.innerHTML = '<div id="last_line" style="margin-left:45%" value="1">到底啦....</div>'
						    table.appendChild(li);
							w.close();
							mui.alert("没有数据啦！");
							}
						}
					},
					error: function() {
						w.close();
						alert("网络连接出错！");
					}

				});
			}, 500);
			mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //参数为true代表没有更多数据了。

		}

		//下拉刷新具体业务实现
		function pulldownRefresh() {
			setTimeout(function() {
				page = 1;
				checkIt();
			}, 500);
			mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
		}

		//	<!--倒计时显示-->
		var sum = 1;
		$(function() {
			get_timer();
		});

		function get_timer() {
			$.ajax({
				contentType: "application/json",
				type: "get",
				url: url_3 + "jobitem_ensureend.do?jsoncallback=?",
				data: "user_id=" + user_id,
				dataType: "json",
				success: function(data) {
					if(data.flag == 1) {
						//获取当前时间
						var myDate = new Date();
						Year = myDate.getYear();
						Month = myDate.getMonth(); //获取当前月份(0-11,0代表1月)
						Day = myDate.getDate(); //获取当前日(1-31)
						Hour = myDate.getHours(); //获取当前小时数(0-23)
						Minute = myDate.getMinutes(); //获取当前分钟数(0-59)
						Second = myDate.getSeconds(); //获取当前秒数(0-59)
						//json获取倒计时时间
						var year = data.msg.time.year,
							month = data.msg.time.month,
							day = data.msg.time.day,
							hour = data.msg.time.hour,
							minute = data.msg.time.minute,
							second = data.msg.time.second; //时间默认值     
						var m = parseInt(minute * 60);
						var s = parseInt(second);
						var h = parseInt(hour * 3600);
						var M = parseInt(Minute * 60);
						var S = parseInt(Second);
						var H = parseInt(Hour * 3600);
						var time1 = parseInt(h + m + s);
						var time2 = parseInt(H + M + S);
						if(time1 < time2) {
							sum = parseInt(86400 - time2 + time1);
						} else {
							sum = parseInt(time1 - time2);
						}
						timer(sum);
					} else {
						document.getElementById("count_down").style.display = "none";
						return;
					}

				},
				error: function(data) {
					alert(data);
					alert("网络连接出错！");
				}
			});

		}

		function timer(sum) {
			var intDiff = parseInt(sum);
			window.setInterval(function() {
				if(intDiff > 0) {
					day = Math.floor(intDiff / (60 * 60 * 24));
					hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
					minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
					second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
				}
				if(minute <= 9) minute = '0' + minute;
				if(second <= 9) second = '0' + second;
				$('#day_show').html(day + "天");
				$('#hour_show').html('<s id="h"></s>' + hour + '时');
				$('#minute_show').html('<s></s>' + minute + '分');
				$('#second_show').html('<s></s>' + second + '秒');
				intDiff--;
				if(intDiff == 0) {
					document.getElementById("count_down").style.display = "none";
					mui.alert("你的订单已确认！");

				}
			}, 1000);
		}

		//根据工种和地址筛选 显示订单
		function jobtype_choose(id) {
			$("#input_search").val("");
			console.log(id)
			var w = plus.nativeUI.showWaiting("正在加载...\n");
			var types = "";
			var a = document.getElementById(id);
			jumpFlag = 2;
			if(id > 20) {
				page = 1;
				$("#show").empty();
				if(a.className == "mui-btn mui-btn-primary") {
					a.setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined");
					a.setAttribute("style", "background-color:white;font-weight:bolder;font-size: 18px;");
				} else {
					a.setAttribute("class", "mui-btn mui-btn-primary");
					a.setAttribute("style", "background-color:;font-weight:bolder;font-size: 18px;");
				}
			}
			if(document.getElementById("21").className == "mui-btn mui-btn-primary") {
				types += "21" + "_";
			}
			if(document.getElementById("22").className == "mui-btn mui-btn-primary") {
				types += "22" + "_";
			}
			if(document.getElementById("23").className == "mui-btn mui-btn-primary") {
				types += "23" + "_";
			}
			if(document.getElementById("25").className == "mui-btn mui-btn-primary") {
				types += "25" + "_";
			}
			if(document.getElementById("33").className == "mui-btn mui-btn-primary") {
				types += "33" + "_";
			}
			if(document.getElementById("41").className == "mui-btn mui-btn-primary") {
				types += "41" + "_";
			}
			console.log("显示已选工种id：" + types);
			setTimeout(function() {
				var table = document.body.querySelector('.mui-table-view');
				var cells = document.body.querySelectorAll('.mui-table-view-cell');
				$.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_3 + "show_jobitems.do?jsoncallback=?",
					data: "jobtype_id=" + types + "&county_code=" + county_code + "&user_id=" + user_id + "&page_num=" + page,
					dataType: "json",
					success: function(data) {
						page++;
						console.log("chooosepage" + page)
						console.log("chooosepage长度" + data.msg.length)
						if(data.msg != null && data.msg.length > 0) {
							console.log(data.msg.length)
							var cells = document.body.querySelectorAll('.mui-table-view-cell');
							for(i = 0, num = 0; i < data.msg.length; i++) {
								var li = document.createElement('li');
								li.className = 'mui-card';
								num = i + page * 10 - 20
								if(data.msg[i] == null) {
									mui.alert("没有数据了！");
									//$("#worry").innerHTML="没有更多数据了！";
									return;
								} else {
									if(data.msg[i].jobitem.job.decoration_type == 1) {
										house = "毛坯";
									} else {
										house = "旧房改造";
									}
									if(data.msg[i].jobitem.unit == 1) {
										unit = "平米";
									} else {
										unit = "延米";
									}
									li.innerHTML = '<table class="p0Style" style="margin-left:10px" ><tr><td class=" mui-badge mui-badge-warning"><h4>' + data.msg[i].jobitem.jobtype.name + '</h4></td><td class=" mui-badge mui-badge-green" id="urgent_fee_' + data.msg[i].jobitem.id + '" style="display: none;"><h4>加急费:' + data.msg[i].jobitem.urgent_fee + '</h4></td><td class=" p4Style"><h3>' + data.msg[i].jobitem.job.community + '</h3></td></tr><br />' +
										'<tr class="p4Style"><td style="color:#ECB100;">面积：' + data.msg[i].jobitem.area + unit + '</td></h6></tr>' +
										'<tr id="show' + num + '"><td class="mui-pull-left">技能:</td></tr>' +
										'<table class="p4Style" style="margin-left:10px" ><tr><td>房屋类型：' + house + '</td>' +
										'<td>&nbsp;&nbsp;&nbsp;酬劳：' + data.msg[i].jobitem.salary + '元</td></tr>' +
										'<tr><td class="mui-pull-left">接单：' + data.msg[i].user_num + '人</td></tr></table>' +
										'<table class="mui-pull-right" style="margin-left:10px" ><tr><td><input type="submit" value="详情" class="mui-pull-right" onclick="order_info(' + data.msg[i].jobitem.id + ',' + data.msg[i].jobitem.job.user.id + ',' + flag + ')">&nbsp;</td>' +
										'<td><input type="submit" value="接单" id="get_order_' + data.msg[i].jobitem.id + '" class="mui-pull-right"  onclick="get_order_onclick(' + data.msg[i].jobitem.id + ')">&nbsp;</td>' +
										'<td><input type="submit" value="分享" class="mui-pull-right">&nbsp;</td><td>&nbsp;</td></tr><tr><td style="height:2px"> </td></tr></table>'
									table.appendChild(li);
									for(z = 0; z < data.msg[i].skills.length; z++) {
										$("#show" + num).append(
											'<td id="p' + data.msg[i].skills[z].id + 'Style" class="mui-pull-left">' + data.msg[i].skills[z].name + '&nbsp;</td>'
										);
										if(data.msg[i].jobitem.urgent_fee != 0) {
											document.getElementById("urgent_fee_" + data.msg[i].jobitem.id).setAttribute("style", "display: ;");
										}
									}
								}
							}
							w.close();
						} else {
							if($("#last_line").text()=="到底啦...."){
								w.close();
							    mui.alert("没有数据啦！");
							    return;
							}else{
							console.log($("#last_line").text())
							var li = document.createElement('li');
							li.className = 'mui-card';  
							li.innerHTML = '<div id="last_line" style="margin-left:45%" value="1">到底啦....</div>'
						    table.appendChild(li);
							w.close();
							mui.alert("没有数据啦！");
							}
						}
					},
					error: function() {
						w.close();
						alert("网络连接出错！");
					}

				});
			}, 500);
			mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
		}
	</script>

</html>